% Flat-field correction example
% EGC 2009/04/21
path1 = ['D:\Users\Data\IVIS\Imaging Session 5 04-15-2009\' ...
    'AEK20090415141520_SEQ\AEK20090415141520_001'];
% -------------------------------------------------------------------------
R = imread([path1...
    '\luminescent.TIF']);                   % Raw Image
D = imread([path1...
    '\readbiasonly.TIF']);                  % Bias (Dark) Image
F = imread([path1...
    '\fluorescentreference.TIF']);          % Fluorescent reference
P = imread([path1...
    '\photograph.TIF']);                    % Photographic Image
P = imresize(P,[256 256]);                  % Resizing
% -------------------------------------------------------------------------
I = double(R - D) ./ double(F - D);         % Flat-field correction
M = F - D;
M = mean(M(:));                             % Determine the average pixel 
                                            % value M in the corrected flat
                                            % frame (F - D).
I = M * I;                                  % Corrected Image
% -------------------------------------------------------------------------
figure; imagesc(R); colormap gray; colorbar; set (gcf,'color','white');...
axis square; axis off; title('Raw Fluorescence Image','Fontsize',18);
figure; imagesc(D); colormap gray; colorbar; set (gcf,'color','white');...
axis square; axis off; title('Bias (Dark) Image','Fontsize',18);
figure; imagesc(F); colormap gray; colorbar; set (gcf,'color','white');...
axis square; axis off; title('Flat Image','Fontsize',18);
figure; imagesc(P); colormap gray; colorbar; set (gcf,'color','white');...
axis square; axis off; title('Photographic Image for reference',...
'Fontsize',18);
figure; imagesc(I); colormap gray; colorbar; set (gcf,'color','white');...
axis square; axis off; title('Corrected Image','Fontsize',18);
% -------------------------------------------------------------------------